#!/bin/bash
# author  Anta Huang
APN="CREATE TABLE \`apn\` (
\`id\` int(11) NOT NULL AUTO_INCREMENT,
\`apn-name\` varchar(60) NOT NULL,
\`pdn-type\` enum('IPv4','IPv6','IPv4v6','IPv4_or_IPv6') NOT NULL,
PRIMARY KEY (\`id\`),
UNIQUE KEY \`apn-name\` (\`apn-name\`)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;"

MMEIDENTITY="CREATE TABLE \`mmeidentity\` (
\`idmmeidentity\` int(11) NOT NULL AUTO_INCREMENT,
\`mmehost\` varchar(255) DEFAULT NULL,
\`mmerealm\` varchar(200) DEFAULT NULL,
\`UE-Reachability\` tinyint(1) NOT NULL COMMENT 'Indicates whether the MME supports UE Reachability Notifcation',
PRIMARY KEY (\`idmmeidentity\`)
) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=latin1;"

PDN="CREATE TABLE \`pdn\` (
  \`id\` int(11) NOT NULL AUTO_INCREMENT,
  \`apn\` varchar(60) NOT NULL,
  \`pdn_type\` enum('IPv4','IPv6','IPv4v6','IPv4_or_IPv6') NOT NULL DEFAULT 'IPv4',
  \`pdn_ipv4\` varchar(15) DEFAULT '0.0.0.0',
  \`pdn_ipv6\` varchar(45) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT '0:0:0:0:0:0:0:0',
  \`aggregate_ambr_ul\` int(10) unsigned DEFAULT '50000000',
  \`aggregate_ambr_dl\` int(10) unsigned DEFAULT '100000000',
  \`pgw_id\` int(11) NOT NULL,
  \`users_imsi\` varchar(15) NOT NULL,
  \`qci\` tinyint(3) unsigned NOT NULL DEFAULT '9',
  \`priority_level\` tinyint(3) unsigned NOT NULL DEFAULT '15',
  \`pre_emp_cap\` enum('ENABLED','DISABLED') DEFAULT 'DISABLED',
  \`pre_emp_vul\` enum('ENABLED','DISABLED') DEFAULT 'DISABLED',
  \`LIPA-Permissions\` enum('LIPA-prohibited','LIPA-only','LIPA-conditional') NOT NULL DEFAULT 'LIPA-only',
  PRIMARY KEY (\`id\`,\`pgw_id\`,\`users_imsi\`),
  KEY \`fk_pdn_pgw1_idx\` (\`pgw_id\`),
  KEY \`fk_pdn_users1_idx\` (\`users_imsi\`)
) ENGINE=MyISAM AUTO_INCREMENT=60 DEFAULT CHARSET=latin1;"
PGW="CREATE TABLE \`pgw\` (
  \`id\` int(11) NOT NULL AUTO_INCREMENT,
  \`ipv4\` varchar(15) NOT NULL,
  \`ipv6\` varchar(39) NOT NULL,
  PRIMARY KEY (\`id\`),
  UNIQUE KEY \`ipv4\` (\`ipv4\`),
  UNIQUE KEY \`ipv6\` (\`ipv6\`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;"

TERMINAL_INFO="CREATE TABLE \`terminal-info\` (
  \`imei\` varchar(15) NOT NULL,
  \`sv\` varchar(2) NOT NULL,
  UNIQUE KEY \`imei\` (\`imei\`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;"

USERS="CREATE TABLE \`users\` (
  \`imsi\` varchar(15) NOT NULL COMMENT 'IMSI is the main reference key.',
  \`msisdn\` varchar(46) DEFAULT NULL COMMENT 'The basic MSISDN of the UE (Presence of MSISDN is optional).',
  \`imei\` varchar(15) DEFAULT NULL COMMENT 'International Mobile Equipment Identity',
  \`imei_sv\` varchar(2) DEFAULT NULL COMMENT 'International Mobile Equipment Identity Software Version Number',
  \`ms_ps_status\` enum('PURGED','NOT_PURGED') DEFAULT 'PURGED' COMMENT 'Indicates that ESM and EMM status are purged from MME',
  \`rau_tau_timer\` int(10) unsigned DEFAULT '120',
  \`ue_ambr_ul\` bigint(20) unsigned DEFAULT '50000000' COMMENT 'The Maximum Aggregated uplink MBRs to be shared across all Non-GBR bearers according to the subscription of the user.',
  \`ue_ambr_dl\` bigint(20) unsigned DEFAULT '100000000' COMMENT 'The Maximum Aggregated downlink MBRs to be shared across all Non-GBR bearers according to the subscription of the user.',
  \`access_restriction\` int(10) unsigned DEFAULT '60' COMMENT 'Indicates the access restriction subscription information. 3GPP TS.29272 #7.3.31',
  \`mme_cap\` int(10) unsigned zerofill DEFAULT NULL COMMENT 'Indicates the capabilities of the MME with respect to core functionality e.g. regional access restrictions.',
  \`mmeidentity_idmmeidentity\` int(11) NOT NULL DEFAULT '0',
  \`key\` varbinary(16) NOT NULL DEFAULT '0' COMMENT 'UE security key',
  \`RFSP-Index\` smallint(5) unsigned NOT NULL DEFAULT '1' COMMENT 'An index to specific RRM configuration in the E-UTRAN. Possible values from 1 to 256',
  \`urrp_mme\` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'UE Reachability Request Parameter indicating that UE activity notification from MME has been requested by the HSS.',
  \`sqn\` bigint(20) unsigned zerofill NOT NULL,
  \`rand\` varbinary(16) NOT NULL,
  \`OPc\` varbinary(16) DEFAULT NULL COMMENT 'Can be computed by HSS',
  PRIMARY KEY (\`imsi\`,\`mmeidentity_idmmeidentity\`),
  KEY \`fk_users_mmeidentity_idx1\` (\`mmeidentity_idmmeidentity\`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;"

